package com.itpuyang.thread;

public class Cooker extends Thread {

    @Override
    public void run() {
        while(true){
            synchronized (Desk.lock){
                if (Desk.count == 0){
                    break;
                }else{
                    if (!Desk.flag){
                        //生产汉堡包
                        System.out.println("厨师正在生产汉堡包");
                        Desk.flag = true;
                        Desk.lock.notifyAll();
                    }else{
                        //存在汉堡包，生产者等待
                        try {
                            Desk.lock.wait();
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }

                    }
                }

            }
        }


    }
}
